
import time
from selenium import webdriver
from selenium.webdriver import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver import ChromeOptions

option = ChromeOptions()
option.add_experimental_option('excludeSwitches',['enable-automation'])
option.add_experimental_option('useAutomationExtension',False)
driver = webdriver.Chrome(options=option)
driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument",{'source':'Object.defineProperty(navigator,"webdriver",{get:()=>undefind})'})
driver.get("https://www.baidu.com")
# 浏览器最大化
driver.maximize_window()
driver.find_element(By.ID,"kw").send_keys("露易丝")
driver.find_element(By.ID,"su").click()
time.sleep(3)

# ctrl+a 全选
driver.find_element_by_id("kw").send_keys(Keys.CONTROL,'a')
# ctrl+x 剪切
driver.find_element_by_id("kw").send_keys(Keys.CONTROL,'x')
time.sleep(3)

driver.find_element_by_id("kw").send_keys("伊蕾娜")
driver.find_element_by_id("su").click()
time.sleep(3)
driver.quit()